const express = require('express')
const path = require('path')
const fs = require('fs')
const config = require(process.cwd() + '/src/config/config')

let router = express.Router()

/* GET users listing. */
router.get('/', function(req, res) {  
  // env文件夹里的子文件就是所有环境设定
  fs.promises.readdir(config.envPath).then((files) => {
    files = files.map(file => path.basename(file, '.json'))
    res.json(files)
  })
  .catch((err) => {
    console.log(err)
    res.sendStatus(500)
  })
})

module.exports = router
